package cn.tedu._01mvcboot01.controller;

import cn.tedu._01mvcboot01.pojo.dto.UserLoginDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class UserController {
    @GetMapping ("/v1/users/login1")
    @ResponseBody
    public String login(String username, String password){
        System.out.println(username+" "+password);
        return "登录成功1"+username+" "+password;
    }
    @PostMapping("/v1/users/login2")
    @ResponseBody
    public String login2(UserLoginDTO userLoginDTO){
        System.out.println(userLoginDTO);
        return "登录成功2"+userLoginDTO.getUsername()+" "+userLoginDTO.getPassword();
    }

    @RequestMapping("/bmi/{weight}/{height}")
    @ResponseBody
    public String bmi2(@PathVariable double weight,@PathVariable double height) {
        double bmi = weight / (height * height);
        if (bmi < 18.5) {
            return "过轻bmi{}";
        } else if (bmi < 24) {
            return "正常bmi{}";
        } else if (bmi < 27) {
            return "过重bmi{}";
        } else {
            return "肥胖bmi{}";
        }

    }
}
